package com.yu.crm.enums;

import com.yxzz.common.exception.ValidateException;

public enum ActionStatus {

    LAUNCH("1", "发起"),
    REJECT("2", "驳回"),
    AGREE("3", "同意");


    private String key;
    private String value;

    ActionStatus(String key, String value) {
        this.key = key;
        this.value = value;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }

    public static boolean validate(String key) {
        for (ActionStatus o : ActionStatus.values()) {
            if (key .equals(o.getKey())) {
                return true;
            }
        }
        throw new ValidateException("无效的审批状态:" + key);
    }

    public static String getKeyByValue(String value) {
        for (ActionStatus o : ActionStatus.values()) {
            if (value.equals(o.value))
                return o.key;
        }
        return null;
    }

    public static String getValueByKey(String key) {
        for (ActionStatus o : ActionStatus.values()) {
            if (key.equals(o.key))
                return o.value;
        }
        return null;
    }
}
